# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=libaccounts-qt
pkgver=1.17
pkgrel=2
arch="all"
url="https://gitlab.com/accounts-sso/libaccounts-qt"
pkgdesc="Qt-based client library for the accounts database"
license="LGPL-2.1-or-later"
depends_dev="
	${pkgname}5
	${pkgname}6
	libaccounts-glib-dev
	"
makedepends="$depends_dev
	doxygen
	graphviz
	qt5-qtbase-dev
	qt5-qttools-dev
	qt6-qtbase-dev
	qt6-qttools-dev
	"
subpackages="${pkgname}5:_qt5 ${pkgname}6:_qt6 $pkgname-dev $pkgname-doc"
source="https://gitlab.com/accounts-sso/libaccounts-qt/-/archive/VERSION_$pkgver/libaccounts-qt-VERSION_$pkgver.tar.gz"
options="!check" # Requires systemd feature
builddir="$srcdir/$pkgname-VERSION_$pkgver"

build() {
	mkdir "$builddir"/qt6 && cd "$builddir"/qt6
	/usr/lib/qt6/bin/qmake .. \
		PREFIX=/usr \
		LIBDIR=/usr/lib
	make

	mkdir "$builddir"/qt5 && cd "$builddir"/qt5
	/usr/lib/qt5/bin/qmake .. \
		PREFIX=/usr \
		LIBDIR=/usr/lib
	make
}

check() {
	cd "$builddir"/qt6
	make check
}

package() {
	cd "$builddir"/qt6
	INSTALL_ROOT="$pkgdir" make install

	cd "$builddir"/qt5
	INSTALL_ROOT="$pkgdir" make install

	# Remove installed test
	rm "$pkgdir"/usr/bin/accountstest
}

_qt5() {
	amove usr/lib/libaccounts-qt5*
}

_qt6() {
	amove usr/lib/libaccounts-qt6*
}

sha512sums="
8d44be27e9724d60aa5fc2dfabf578c71fdb9f8cca5711ac765d5211c5fd28bef435e0534d6bd0921ac4e111b6c33924504a8393b8d6ca09d25d74ec26f3a9e1  libaccounts-qt-VERSION_1.17.tar.gz
"
